//
//  MainViewController.m
//  FreightAssistant
//
//  Created by leo on 15/10/27.
//  Copyright © 2015年 leo. All rights reserved.
//

#import "MainViewController.h"

#import "PurchaseOrderEditViewController.h"
#import "SupplyOrderEditViewController.h"

@interface MainViewController () {
    
    UIView *_kk_pannelView;
    UIButton *_kk_shippingButton;
    UIButton *_kk_purchasingButton;
}

@end

@implementation MainViewController

- (void)loadView {
    [super loadView];
    
    
    _kk_pannelView = [[UIView alloc] initWithFrame: CGRectMake(40, 150, CGRectGetWidth(self.view.bounds) - 80, CGRectGetHeight(self.view.bounds) - 130)];
    _kk_pannelView.backgroundColor = [UIColor colorWithWhite: 0.1 alpha: 0.1];
    _kk_pannelView.layer.cornerRadius = 5;
    _kk_pannelView.layer.masksToBounds = true;
    [self.view addSubview: _kk_pannelView];
    {
        UILabel *titleLabel = [[UILabel alloc] initWithFrame: CGRectMake(0, 0, CGRectGetWidth(_kk_pannelView.bounds), 40)];
        titleLabel.backgroundColor = [UIColor colorWithHexString: @"#00bdff"];
        titleLabel.textAlignment = NSTextAlignmentCenter;
        titleLabel.textColor = [UIColor whiteColor];
        titleLabel.text = @"新增订单";
        [_kk_pannelView addSubview: titleLabel];
        
        UIButton *shippingButton = [UIButton buttonWithType: UIButtonTypeCustom];
        shippingButton.frame = CGRectMake(40, 100, CGRectGetWidth(_kk_pannelView.bounds) - 80, 40);
        shippingButton.backgroundColor = [UIColor colorWithHexString: @"#00bdff"];
        shippingButton.layer.cornerRadius = 5;
        [shippingButton setTitle: @"海运订单" forState: UIControlStateNormal];
        [shippingButton setTitleColor: [UIColor lightGrayColor] forState: UIControlStateHighlighted];
        [shippingButton addTarget: self action: @selector(onClick:) forControlEvents: UIControlEventTouchUpInside];
        [_kk_pannelView addSubview: shippingButton];
        _kk_shippingButton = shippingButton;
        
        
        UIButton *purchasingButton = [UIButton buttonWithType: UIButtonTypeCustom];
        purchasingButton.frame = CGRectMake(40, CGRectGetMaxY(shippingButton.frame) + 30, CGRectGetWidth(_kk_pannelView.bounds) - 80, 40);
        purchasingButton.backgroundColor = [UIColor colorWithHexString: @"#00bdff"];
        purchasingButton.layer.cornerRadius = 5;
        [purchasingButton setTitle: @"代购订单" forState: UIControlStateNormal];
        [purchasingButton setTitleColor: [UIColor lightGrayColor] forState: UIControlStateHighlighted];
        [purchasingButton addTarget: self action: @selector(onClick:) forControlEvents: UIControlEventTouchUpInside];
        [_kk_pannelView addSubview: purchasingButton];
        _kk_purchasingButton = purchasingButton;
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"代购君";
    
    self.showMainItem = true;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Private methods

- (void)onClick:(UIButton*)item {
    

    if (item == _kk_shippingButton) {
        PurchaseOrderEditViewController *editViewController = [PurchaseOrderEditViewController viewControllerFromStoryboard];
        [self.navigationController pushViewController: editViewController animated: true];
    }
    else {
        SupplyOrderEditViewController *editViewController = [SupplyOrderEditViewController viewControllerFromStoryboard];
        [self.navigationController pushViewController: editViewController animated: true];
    }
}


@end
